#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

string addStrings(string num1, string num2) {
    
    
    int end1 = num1.size() - 1;
    int end2 = num2.size() - 1;
    string str;
    int next = 0;
    while (end1 >= 0 || end2 >= 0)
    {
        int x1 = end1 >= 0 ? num1[end1] - '0' : 0;
        int x2 = end2 >= 0 ? num2[end2] - '0' : 0;
        int tmp = x1 + x2 + next;
        next = tmp / 10;
        tmp %= 10;
        str += (tmp + '0');
        --end1;
        --end2;
    }
    if (next == 1)
    {
        str += ('1');
    }
    reverse(str.begin(), str.end());
    return str;
}

string multiply(string num1, string num2) {
    if (num1 == "0" || num2 == "0")
    {
        return "0";
    }
    int end1 = num1.size() - 1;
    int end2 = num2.size() - 1;
    
    int next = 0;
    int n = 0;
    string str2;
    while (end1 >= 0 || end2 >= 0)
    {
        string str1;
        string tmp;
        n++;
        int x = end2 >= 0 ? num2[end2] - '0' : 0;
        end1= num1.size() - 1;
        while (end1 >= 0)
        {

            int y = num1[end1] - '0';
            int pro = x * y + next;
            next = pro/10;
            tmp += ((pro % 10) + '0');
            end1--;
        }
        /*if (next != 0)
        {
            tmp += (next + '0');
        }*/
        reverse(tmp.begin(),tmp.end());
        for (int i = 1; i < n; i++)
        {
            tmp += '0';
        }
        str2=addStrings(str2,tmp);
            end2--;
    }
    
    return  str2;
    string s;
    s += (next + '0');
    if (next != 0)
    {
        str2.insert(0, s);
    }
}

int main()
{
    string s1("99");
    string s2("99");
    string s3=multiply(s1, s2);
    cout << s3 << endl;
}